﻿using Besture.Common;
using System; 
using System.Data;
using System.Linq;
using Besture.Bll;

namespace Besture.UI.Admin.RoomPrice
{
    public partial class AJaxPrice : System.Web.UI.Page
    {
        private string sHotels = StringHelper.Query("Hotels");
        private string sBm = StringHelper.Query("bm");
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(sHotels))
            {
                InitPage();
            }
        }
         
        public void InitPage()
        {
            int iHotelsID = Convert.ToInt32(sHotels);
            //DataTable tableCity =
            //    QueryDac.GetTable("select * from TBRoom where IsDeleted=0 and HotelsID=" + iHotelsID +
            //                      " order by SortID");
            string sSql = string.Format(
                    "SELECT tbp.RoomName,tbp.ID,tbp.SortID  from TBRoom tbp JOIN TBRoomPrice tbrp ON tbp.ID=tbrp.RoomID where tbp.IsDeleted=0 and tbp.HotelsID={0} GROUP BY tbp.RoomName,tbp.ID,tbp.SortID  order by tbp.SortID ",
                    iHotelsID);
            if (string.IsNullOrWhiteSpace(sBm))
            {
                sSql = string.Format("select * from TBRoom where IsDeleted=0 and HotelsID={0} order by SortID", iHotelsID);
            }   
            DataTable tableCity = QueryDac.GetTable(sSql);
            string sHtml = tableCity.Rows.Cast<DataRow>().Aggregate("&nbsp;&nbsp&nbsp;&nbsp<span>选择房型：</span>&nbsp; ", (current, dr) => current + string.Format("<input type='checkbox' name='Room' value='{0}' />{1}&nbsp;&nbsp", dr["ID"].ToString(), dr["RoomName"].ToString()));
            Response.Write(sHtml);
            
        }


         

    }
}